<?php
namespace app\yunda\model;

use think\Model;
use think\Db;
use traits\model\SoftDelete;

/**
 * 用户订单表
 * @package app\yunda\model
 */
class Order extends Model
{
    use SoftDelete;
    protected $deleteTime = 'delete_time';
    protected $table = 'dp_yd_order';
    protected $autoWriteTimestamp = true;

    //生成油码
    public static function youMaCode()
    {
        $poster_code=rand(1000,9999);
        while (true){
            $is_code=Db::table('dp_yd_order')
                ->whereTime('create_time','d')
                ->where('poster_code',$poster_code)
                ->find();
            if(empty($is_code)) break;
        }
        return $poster_code;
    }
}
